Description:
DCC detects similar code fragments that appear in the class constructors. Such fragments can be moved to a separate method and reused. In effect, maintainability of the code will be improved.
Incorrect:
class Node {
private static int count;
private string name;
Node() {
count++;
}
Node(string name) {
count++;
this.name = name;
}
}
Correct:
class Node {
private static int count;
private string name;
Node() {
count++;
}
Node(string name): this() {
this.name = name;
}
}